import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		// 初始化数据
		commInitInfo: null,
		// 购物车下单商品
		cartShopList:null,
		// 用户信息
		userInfo:null,
		// 店铺信息
		storeInfo:null,
		// 云店or闪电送
		storeType:null,
		// 用户地址信息
		userAddressInfo:null
	},

	mutations: {
		// 获取初始化数据
		getCommInitInfo(state, value) {
			state.commInitInfo = value;
		},

		// 清除初始化数据
		clearAwayCommInitInfo(state, value) {
			state.commInitInfo = null;
		},
		
		// 获取购物车下单商品
		getCartShopList(state, value) {
			state.cartShopList = value;
		},
		
		// 清除购物车下单商品
		clearCartShopList(state, value) {
			state.cartShopList = null;
		},
		
		getuserInfo(state, value){
			state.userInfo = value;
		},
		
		clearUserInfo(state, value){
			state.userInfo = null;
		},
		
		getstoreInfo(state, value){
			state.storeInfo = value;
		},
		
		clearStoreInfo(state, value){
			state.storeInfo = value;
		},
		
		getstoreType(state, value){
			state.storeType = value;
		},
		
		clearStoreType(state, value){
			state.storeType = null;
		},
		
		getUserAddressInfo(state, value){
			state.userAddressInfo = value;
		},
	},

	actions: {
		// 初始化
		getCommInitInfoAsync({
			commit
		}, value) {
			commit('getCommInitInfo', value);
		},
		
		// 购物车下单商品
		getCartShopListAsync({
			commit
		}, value) {
			commit('getCartShopList', value);
		},
		
		getuserInfoAsync({
			commit
		},value){
			commit('getuserInfo', value);
		},
		
		getstoreInfoAsync({
			commit
		},value){
			commit('getstoreInfo', value);
		},
		
		getstoreTypeAsync({
			commit
		},value){
			commit('getstoreType', value);
		},
		
		getUserAddressInfoAsync({
			commit
		},value){
			commit('getUserAddressInfo', value);
		}
	},

	getters: {}
});

export default store;